unit dgIncludePin ;

interface

uses Windows,
   SysUtils,
   Classes,
   Graphics,
   Forms,
   Controls,
   StdCtrls,
   Buttons,
   ExtCtrls,
   CheckLst,
   TntCheckLst,
   SpTBXEditors,
   SpTBXControls,
   TBXDkPanels,
   uBasic,
   uObjects ;

type
   TdlgIncludePins = class( TForm )
      SpTBXPanel1 : TSpTBXPanel ;
      btnOK : TSpTBXButton ;
      btnCancel : TSpTBXButton ;
      SpTBXGroupBox1 : TSpTBXGroupBox ;
      lbPorts : TSpTBXCheckListBox ;
      btCheckAll : TSpTBXButton ;
      btnCheckNone : TSpTBXButton ;
      procedure btnOKClick( Sender : TObject ) ;
      procedure btCheckAllClick( Sender : TObject ) ;
      procedure btnCheckNoneClick( Sender : TObject ) ;
   private
      procedure SetTitle( const Value : string ) ;
   public
      property Title : string write SetTitle ;
      procedure AddPort( aPort : TMedaPort ) ;
   end ;

var
   dlgIncludePins   : TdlgIncludePins ;

implementation

{$R *.dfm}

{ TdlgIncludePins }

procedure TdlgIncludePins.AddPort( aPort : TMedaPort ) ;
var
   iItem            : integer ;
begin
   iItem := lbPorts.Items.AddObject( aPort.Name, aPort ) ;
   lbPorts.Checked[ iItem ] := aPort.GetSelection = TriTrue ;
end ;

procedure TdlgIncludePins.btnCheckNoneClick( Sender : TObject ) ;
var
   i                : integer ;
begin
   for i := 0 to lbPorts.Items.Count - 1 do
      lbPorts.Checked[ i ] := False ;
end ;

procedure TdlgIncludePins.btnOKClick( Sender : TObject ) ;
var
   i                : integer ;
begin
   for i := 0 to lbPorts.Items.Count - 1 do
      if lbPorts.Checked[ i ] then
         TMedaPort( lbPorts.Items.Objects[ i ] ).SetSelection( TriTrue )
      else
         TMedaPort( lbPorts.Items.Objects[ i ] ).SetSelection( TriFalse ) ;
end ;

procedure TdlgIncludePins.SetTitle( const Value : string ) ;
begin
   Caption := Value ;
end ;

procedure TdlgIncludePins.btCheckAllClick( Sender : TObject ) ;
var
   i                : integer ;
begin
   for i := 0 to lbPorts.Items.Count - 1 do
      lbPorts.Checked[ i ] := True ;
end ;

end.

